﻿#region
/*******************************************************************************
** File Name:		    ReasonSettingService.cs
** Creator:		        chao.jiang 
** EMail:               chao.jiang 
** Create date:	        
** Latest Modifier:
** Latest Modify date:
** Description:		    
** Modify History:
**
** Code Review:
**
** Version number:       1.0.0
*********************************************************************************/
#endregion
using System;
using System.Collections.Generic;
using System.Text;
using EWineShop.Service.Contracts;
using EWineShop.Service.Model;
using EWineShop.IBatisRepository;
using EWineShop.Respository;
using System.Data;
using EWineShop.Entity;

namespace EWineShop.Service
{
    public class ReasonSettingService : IReasonSettingService
    {
		 IReasonSetting reasonSetting = new ReasonSettingRepository();
		 
		 #region  Auto Generation
		 

	
		public IList<ReasonSettingModel> GetAll ()
		{
			IList<EReasonSetting> entity = reasonSetting.GetAll();
			
			if (entity == null)
            {
                return null;
            }
            
            IList<ReasonSettingModel> list = new List<ReasonSettingModel>();

            foreach (var item in entity)
            {
                ReasonSettingModel model = ConvertEntityToModel(item);
                list.Add(model);
            }
            return list;   
			
		}
		
		private ReasonSettingModel ConvertEntityToModel(EReasonSetting entity)
		{
			if (entity == null)
            {
                return null;
            }
			ReasonSettingModel model = new ReasonSettingModel();
                        model.ReasonSettingID = entity.ReasonSettingID;
                        model.Type = entity.Type;
                        model.Name = entity.Name;
                        model.CreateTime = entity.CreateTime;
                        model.UpdateTime = entity.UpdateTime;
                        return model;
		}
		
		private EReasonSetting ConvertModelToEntity(ReasonSettingModel model)
		{
			if (model == null)
            {
                return null;
            }
			EReasonSetting entity = new EReasonSetting();
                        entity.ReasonSettingID = model.ReasonSettingID;
                        entity.Type = model.Type;
                        entity.Name = model.Name;
                        entity.CreateTime = model.CreateTime;
                        entity.UpdateTime = model.UpdateTime;
                        return entity;
		}
		
		
		
		#endregion
    }
}